﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using DbSharp.SupportLib.Crypto;
using System.Xml.Linq;
using System.Globalization;
using Microsoft.Win32;


namespace DbSharp.Framework.ReleaseManage
{

    /// <summary>
    /// one service to track evaluation expiration
    /// </summary>
    public interface IEvaluationTrackService
    {
        /// <summary>
        /// get 
        /// </summary>
        /// <returns></returns>
        EvaluationTrackInfo GetEvaluationTrackInfo();


        /// <summary>
        /// to set new tracking info 
        /// </summary>
        /// <param name="newTrackInfo">new track info</param>
        /// <returns>true if runing successful, otherwise false</returns>
        bool TryToSetEvaluationTrackInfo(EvaluationTrackInfo newTrackInfo);
    }


    public class EvaluationTrackInfo
    {
        public int TrialExtendCount { get; set; }
        public DateTime FirstEvaluationTime { get; set; }
        public bool Expired { get; set; }

        public static EvaluationTrackInfo CreateIllegalEvaluationTrackInfo()
        {
            var obj = new EvaluationTrackInfo();
            obj.Expired = true;
            obj.FirstEvaluationTime = DateTime.Now.AddYears(-5);
            obj.TrialExtendCount = 1000;
            return obj;
        }

        public static bool IsIllegalEvaluationTrackInfo(EvaluationTrackInfo trackInfo)
        {
            var illegalTrack = CreateIllegalEvaluationTrackInfo();
            if ((trackInfo.Expired == illegalTrack.Expired)
                && (trackInfo.TrialExtendCount == illegalTrack.TrialExtendCount)
                )
                return true;
            else
                return false;
        }
    }

 
  
}

